Repository navigation
fix(code-executors): render an empty text part when a code execution result has no output - #903
Merged
AmaadMartin merged 2 commits intoSep 16, 2026
Conversation
added 2 commits
September 15, 2026 14:08
…tput convertCodeExecutionParts concatenated codeExecutionResult.output into the tool_output delimiters without a guard. output is optional, so an absent one became the literal string "undefined" in the prompt the model reads next. adk-python guards the same branch with `is not None` and writes an empty text part with no delimiters, so this port matches it. `== null` covers the explicit JSON null an A2A peer or a persisted event can carry, which `=== undefined` would miss. An empty-string output still keeps its delimiters.
Replace the JSON.parse that laundered a null past output?: string with a
visible `as unknown as Part` cast, so the escape is greppable and nothing is
re-parsed at runtime.
Drop the two `.not.toContain(...)` assertions. Each followed a `toBe('')` on
the same value, and the empty string contains no substring, so neither could
ever fail.
Type the parts array instead of the whole content. The `!` on every
`content.parts![0]` goes away, and the tests still typecheck.
Collaborator
|
Merging in about 6h unless someone objects. Close this PR, add |
Collaborator
|
Merging in about 1h unless someone objects. Close this PR, add |
adk-foundry-approver
approved these changes
Sep 16, 2026
adk-foundry-approver
left a comment
Collaborator
There was a problem hiding this comment.
Approved automatically by ADK Foundry. No human has read this change.
This approval attests only that the change passed the gates below, all
enforced in code:
- the merge critic read the diff and approved it (93.9% precision measured
against 107 upstream pull requests with known maintainer outcomes) - ? changed lines across ? file(s), inside the 200/5 ceiling
- no auth, credential, security, release or dependency-manifest path touched
- required checks green, re-verified immediately before this approval
- opened 25h ago and visible as
automerge: scheduledthroughout,
with no objection from anyone
To stop this merging, close the pull request or add status/on-hold. To stop
the mechanism entirely, revoke this account's access; delivery continues and
nothing merges.
Merged
prasanna8585
pushed a commit
to prasanna8585/adk-js
that referenced
this pull request
Nov 10, 2026
…result has no output (google#903) * Fix: render an empty text part when a code execution result has no output convertCodeExecutionParts concatenated codeExecutionResult.output into the tool_output delimiters without a guard. output is optional, so an absent one became the literal string "undefined" in the prompt the model reads next. adk-python guards the same branch with `is not None` and writes an empty text part with no delimiters, so this port matches it. `== null` covers the explicit JSON null an A2A peer or a persisted event can carry, which `=== undefined` would miss. An empty-string output still keeps its delimiters. * Test: address the complexity review on the converter tests Replace the JSON.parse that laundered a null past output?: string with a visible `as unknown as Part` cast, so the escape is greppable and nothing is re-parsed at runtime. Drop the two `.not.toContain(...)` assertions. Each followed a `toBe('')` on the same value, and the empty string contains no substring, so neither could ever fail. Type the parts array instead of the whole content. The `!` on every `content.parts![0]` goes away, and the tests still typecheck.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
No existing issue.
2. Or, if no issue exists, describe the change:
Problem:
convertCodeExecutionPartsconcatenatescodeExecutionResult.outputinto thetool_outputdelimiters without a guard.outputis optional in@google/genai, so an absent output becomes the literal stringundefined. Themodel then reads
```tool_output\nundefined\n```as a real tool result. A partwith no
outputreaches the converter from an A2A data part, from a replayedsession event, or from user-built
Content.Solution:
The converter now writes an empty text part, with no delimiters, when the output
is absent. This matches adk-python, which guards the same branch with
if output is not None. I compare with== nullbecause a deserialized peerpart can carry an explicit
nullat runtime. Anoutputof''keeps itsdelimiters, because adk-python guards on
is not Noneand not on truthiness.Testing Plan
Unit Tests:
Three new cases in
core/test/code_executors/code_execution_utils_test.ts: anabsent output, an explicit
nulloutput, and an empty-string output that keepsits delimiters. No existing test changed.
The tests can fail. With the guard reverted, the first two cases report
'```tool_output\nundefined\n```'and'```tool_output\nnull\n```'instead of
''. With the guard written as a truthiness check, the empty-stringcase loses its delimiters.
Manual End-to-End (E2E) Tests:
No end-to-end test. The converter is a pure synchronous transform with no I/O
and no model call, so the three unit tests observe the whole change.
Checklist
Additional context
buildCodeExecutionResultPartis untouched. This converter guard is stillneeded after that helper is fixed, because the converter also consumes parts
that ADK did not build.